<!doctype html>
<html >
<head>
<meta charset="utf-8">
<title>机构设置</title>
<link   href="images/logo.ico"  rel="shortcut icon" />
<link rel="stylesheet" href="css/xp2.css">
<link rel="stylesheet" href="css/xp1.css">
</head>
<body>
<article class="kontext">
  <div class="layer one show">
    <h2>领导们</h2>
    <p>唐红燕主任、张艳、钟传静、宋谨<br><img src="images/jgsz1.jpg">    </p>
  </div>
  <div class="layer two">
    <h2>老师们</h2>
	<p>王宗婷、肖姐、钟传静、宋谨等等<br><img src="images/jgsz3.jpg"></p>
  </div>
  <div class="layer three">
    <h2>学生会</h2>
	<p>张杰、汤宇翔、何排、何劲峰等等<br><img src="images/jgsz.jpg"></p>
  </div>
</article>
<ul class="bullets">
</ul>
<script src="js/xp3.js"></script>
<script>
			var k = kontext( document.querySelector( '.kontext' ) );

			var bulletsContainer = document.body.querySelector( '.bullets' );
			for( var i = 0, len = k.getTotal(); i < len; i++ ) {
				var bullet = document.createElement( 'li' );
				bullet.className = i === 0 ? 'active' : '';
				bullet.setAttribute( 'index', i );
				bullet.onclick = function( event ) { k.show( event.target.getAttribute( 'index' ) ) };
				bullet.ontouchstart = function( event ) { k.show( event.target.getAttribute( 'index' ) ) };
				bulletsContainer.appendChild( bullet );
			}
			k.changed.add( function( layer, index ) {
				var bullets = document.body.querySelectorAll( '.bullets li' );
				for( var i = 0, len = bullets.length; i < len; i++ ) {
					bullets[i].className = i === index ? 'active' : '';
				}
			} );

			document.addEventListener( 'keyup', function( event ) {
				if( event.keyCode === 37 ) k.prev();
				if( event.keyCode === 39 ) k.next();
			}, false );

			var touchX = 0;
			var touchConsumed = false;

			document.addEventListener( 'touchstart', function( event ) {
				touchConsumed = false;
				lastX = event.touches[0].clientX;
			}, false );

			document.addEventListener( 'touchmove', function( event ) {
				event.preventDefault();

				if( !touchConsumed ) {
					if( event.touches[0].clientX > lastX + 10 ) {
						k.prev();
						touchConsumed = true;
					}
					else if( event.touches[0].clientX < lastX - 10 ) {
						k.next();
						touchConsumed = true;
					}
				}
			}, false );

		</script>
</body>
</html>
